<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
		<link rel="stylesheet" href="css/home.css">
		<link rel="stylesheet" href="css/base.css">
		<link rel="stylesheet" type="text/css" href="css/paging.css">
		<script type="text/javascript" src="js/jquery-3.2.1.js"></script>
		<script type="text/javascript" src="js/index.js"></script>
		<script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="js/url.js"></script>
		<script type="text/javascript" src="js/page/query.js"></script>
		<script type="text/javascript" src="js/page/paging.js"></script>
		<title>企业</title>
		<style>
			#pageToolBox{
				margin: 0 auto;
			}
		</style>
	</head>
	<body>
		<div class="publicSearch_container">
			<div class="header">
				<div class="header_left fl" onclick="index()">
					<img src="images/publicLogo.jpg" />
				</div>
				<div class="fl header_middle">
					<ul class="fl">
						<li>
							舆情
						</li>
						<li>
							企业
						</li>
						<li class="header-selected">
							产品
						</li>
					</ul>
					<div class="searchbox fr">
						<input id="search_1" value=" "><span id="souSou" onclick="souSou()">搜索</span>
						<div class="searchIcon"><img src="images/search.png" /></div>
					</div>
				</div>
				<!--<div class="header_right fr">
					<ul class="clearfix">
						<li id="exit"><img src="images/exit.png" /></li>
						<li onclick="javascript:window.location='my-custom.html'">我的定制</li>
						<li><img src="images/line.png" /></li>
						<li onclick="javascript:window.location='personal-setting.html'">Kimi</li>
						<li onclick="javascript:window.location='personal-setting.html'" class="nav_img"><img src="images/header.png" /></li>
					</ul>
				</div>-->
			</div>
			<div class="product-box company-public-box">
				<div class="product-list">
					<!--一条数据-->

					<!--<div class="clearfix company-item" onclick="javascript:window.location='productDetail.html'">-->
					<!--<div class="company-left fl">
							<div class="fl company-img">
								<img src="images/company.png" />
							</div>
							<div class="fl">
								<div class="company-title">企雷达科技有限公司</div>
								<div class="clearfix company-txt">
									<ul class="company-keyword fl"> 
										<li>关键词:</li>
										<li>环境</li>
										<li>员工友善</li>
										<li>创业</li>
									</ul>
									<div class="fl company-article"><span>相关文章：</span><span>54485</span></div>
								</div>
								<p class="fl item-content2"><span class="positive">正</span><a href="#"><span  class="item-content-title">企雷达</span>产品正在试产试销中</a>
									<span class="item-content2-source">东方财富网</span>
								</p>
							</div>	
						</div>	
						<div class="fr company-right">
								
							<div class="header-hot clearfix">
								<div class="fl header-hot-txt">热度指数</div>
								<div class="hot-progress fl">
									<div class="progress-val" id="bar_width">5642</div>
									<div class="progress-bar">
										<span class="progress-in" id="bar"></span>
									</div>
								</div>
							</div>
							
							<div class="company-time-more"><span class="company-time">2018-03-25</span><span class="company-more">更多</span></div>
						</div>-->
					<!--</div>-->
				</div>
			</div>
			<!--<div id="pageToolBox">
				<div id="pageTool"></div>
			</div>-->
		</div>
	</body>
</html>
<script>
	$(document).ready(function() {
		load();
	});
	var total;
	var token = sessionStorage.getItem('token');
	console.log(token);
	function index() {
		if(token ==null) {
			window.location = "index.html";
		} else {
			window.location = "index-logged.html";
		}
	}
	//搜索函数					
	var souSou = function() {
		load();
	};
	//按下回车键事件
	$("#search_1").keydown(function() {
		if(event.keyCode == "13") {
			load();
		};
	});
	var product = function(data) {
		var data = JSON.stringify({
			'pro_name': $('#search_1').val(),
			'pageNum': 1,
			'pageSize': 10,
		});

		$.ajax({
			type: "post",
			url: 'http://139.224.208.224:8080/qi-radar/product/getProductList',
			dataType: 'json',
			contentType: "application/json ",
			async: false,
			data: data,
			success: function(data) {
				if(data.code == 0) {
					total=data.total;
					var data = data.data;
					console.log(data)
					var list = '';
					for(var i = 0; i < data.length; i++) {
						var carNewsList = '';
						$.each(data[i].keyword, function(i, item) {
							carNewsList += "<li>" + item.keyword_name + "</li>";
						});
						list += "<div class=\"clearfix company-item\" onclick=\"productDetail(this)\" data-id=\"" + data[i].id + "\" data-name=\"" + data[i].pro_name + "\" >";
						list += "<div class=\"company-left fl\">";
						list += "<div class=\"fl company-img\">";
						list += "<img src=\"images/company.png\" />";
						list += "</div>";
						list += "<div class=\"fl\">";
						list += "<div class=\"company-title\">" + data[i].pro_name + "</div>";
						list += "<div class=\"clearfix company-txt\">";
						list += "<ul class=\"company-keyword fl\">";
						list += "<li>关键词:</li>";
						list += carNewsList;
						//							list += "<li>"+data[i].keyword[1].keyword_name+"</li>";
						list += "</ul>";
						list += "<div class=\"fl company-article\"><span>相关文章：</span><span>" + data[i].aboutArticle + "</span></div>";
						list += "</div>";
						//							list += "<p class=\"fl item-content2\"><span class=\"negative\">反</span><a href=\"#\"><span  class=\"item-content-title\">"+data[i].newwestArticle.vrtitle+"</a>";
						list += "</p>";
						list += "</div>";
						list += "</div>";
						list += "<div class=\"fr company-right\">";
						list += "<div class=\"header-hot clearfix\">";
						list += "<div class=\"fl header-hot-txt\">热度指数</div>";
						list += "<div class=\"hot-progress fl\">";
						list += "<div class=\"progress-val\" id=\"bar_width\">" + data[i].heatvalue + "</div>";
						list += "<div class=\"progress-bar\">";
						list += "<span class=\"progress-in\" id=\"bar\"></span>";
						list += "</div>";
						list += "</div>";
						list += "</div>";
						//							list += "<div class=\"company-time-more\"><span class=\"company-time\">"+data[i].newwestArticle.ctime+"</span><span class=\"company-more\">更多</span></div>";
						list += "</div>";
						list += "</div>";
						list += "</div>";

					}
					$(".product-box").html(list);
					paged();

				} else {
					alert(data.errMsg)
				}
			}
		});
	};
	//分页
	function load(){
		var data = JSON.stringify({
			'pro_name': $('#search_1').val(),
			'pageNum': 1,
			'pageSize': 10,
		});
		product(data)
	};
	var pages;
	function paged() {
		$('#pageTool').empty();
		$('#pageTool').Paging({
			pagesize: 10,
			count:total,
			current:pages,
			callback: function(page, size, count) {
				var data = JSON.stringify({
					'pro_name': $('#search_1').val(),
					'pageNum': page,
					'pageSize': 10,
				});
				pages=page;
				product(data);
			}
		});
	};
	
	function productDetail(a) {
		var id = $(a).attr('data-id');
		var name = $(a).attr('data-name');
		var searchText = jQuery.trim($("#search_1").val());
		window.location.href = "productDetail.html?id=" + id + "&name=" + name + "&searchText=" + searchText;
	};
</script>